import 'device_model.dart';

class BleBatchConfigResult {
  final String uuid;
  final bool success;
  final ThingSmartDeviceModel? device;
  final String? errorCode;
  final String? errorMessage;

  BleBatchConfigResult({
    required this.uuid,
    required this.success,
    this.device,
    this.errorCode,
    this.errorMessage,
  });

  factory BleBatchConfigResult.fromJson(Map<String, dynamic> json) {
    final deviceData = json['device'];
    return BleBatchConfigResult(
      uuid: json['uuid'] as String? ?? '',
      success: json['success'] as bool? ?? false,
      device: deviceData is Map
          ? ThingSmartDeviceModel.fromJson(
              Map<String, dynamic>.from(deviceData as Map),
            )
          : null,
      errorCode: json['errorCode']?.toString(),
      errorMessage: json['errorMessage'] as String?,
    );
  }
}
